package com.smt.ejb3.tutoria.client;

import javax.naming.InitialContext;
import javax.naming.NamingException;

import com.smt.ejb3.tutoria.entitybean.tableperclass.Lamb;
import com.smt.ejb3.tutoria.entitybean.tableperclass.Meat;
import com.smt.ejb3.tutoria.entitybean.tableperclass.Pork;
import com.smt.ejb3.tutoria.service.MappingService;

public class MeatClient {
	public static void main(String[] args) {
		
		Meat m = new Meat();
		m.setId(0);
		m.setName("meat");
		
		
		Lamb l = new Lamb();
		l.setId(1);
		l.setName("lamb");
		l.setLamb("lll");
		
		Pork p = new Pork();
		p.setId(2);
		p.setName("pork");
		p.setPork("ppp");
		
		try {
			InitialContext ctx = new InitialContext();

			MappingService service = (MappingService) ctx
					.lookup("MappingServiceImpl/remote");
			/* Save Meat */
//			service.saveMeat(m);
//			service.saveMeat(l);
//			service.saveMeat(p);
			
			/* Find Meat */
			Meat mm = service.findMeat(1);
			Lamb ll = (Lamb)mm;
			System.out.println(ll.getLamb());
			

		} catch (NamingException ex) {
			ex.printStackTrace();
		}
	}
}
